package IO2;

import java.io.*;
import java.lang.reflect.Field;

/**
 * @description: IO_operation01
 * IO流标准步骤
 * 1.创建源
 * 2.选择流
 * 3.操作
 * 4.释放
 * ps；包含了一些 异常检测（try catch）
 * @date: 2019/12/16 21:19
 * @author: Vicuna
 */


public class IO_operation01 {
    public static void main(String[] args) {
        // 1.创建源
        File f = new File("E:/Code/Java练习/IO/src/IO2/aaa.txt");
        //2.选择流
        InputStream is = null;
        try {
            is = new FileInputStream(f);
            //3.操作 按字节读取
            int temp;
            //文件末尾输出-1
            while ((temp = is.read()) != -1) {
                System.out.println((char) temp);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
        //4.释放
            try {
                if(null!=is)
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
